package cn.yerly.sakura.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;

/**
 * A ShippingCompany.
 */
@Entity
@Table(name = "SHIPPINGCOMPANY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName="shippingcompany")
public class ShippingCompany implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @NotNull
    @Size(max = 64)
    @Column(name = "name", length = 64, nullable = false)
    private String name;

    @NotNull
    @Size(max = 64)
    @Column(name = "web", length = 64, nullable = false)
    private String web;

    @Size(max = 256)
    @Column(name = "query_url", length = 256)
    private String queryUrl;

    @Size(max = 32)
    @Column(name = "tel", length = 32)
    private String tel;

    @Column(name = "disabled")
    private Boolean disabled;

    @OneToOne
    private Image logo;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWeb() {
        return web;
    }

    public void setWeb(String web) {
        this.web = web;
    }

    public String getQueryUrl() {
        return queryUrl;
    }

    public void setQueryUrl(String queryUrl) {
        this.queryUrl = queryUrl;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    public Image getLogo() {
        return logo;
    }

    public void setLogo(Image image) {
        this.logo = image;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        ShippingCompany shippingCompany = (ShippingCompany) o;

        if ( ! Objects.equals(id, shippingCompany.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "ShippingCompany{" +
                "id=" + id +
                ", name='" + name + "'" +
                ", web='" + web + "'" +
                ", queryUrl='" + queryUrl + "'" +
                ", tel='" + tel + "'" +
                ", disabled='" + disabled + "'" +
                '}';
    }
}
